
import 'package:fisrt_a/baseWidget/ButtonDemo.dart';
import 'package:fisrt_a/baseWidget/ImageAndIcon.dart';
import 'package:fisrt_a/baseWidget/ProgressIndicatorDemo.dart';
import 'package:fisrt_a/baseWidget/SwitchAndCheckbox.dart';
import 'package:fisrt_a/baseWidget/TextFieldDemo.dart';
import 'package:fisrt_a/baseWidget/textDemo.dart';
import 'package:flutter/material.dart';

class BaseDemo extends StatelessWidget {
@override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
  appBar: AppBar(
    title: Text('基础组件'),
  ),
  body: Center(
    child: new ListView.separated(itemBuilder: (context,item){
      return buidData(context, listData[item], iconsData[item],item);
    }, separatorBuilder: (BuildContext context,int index) => new Divider(), itemCount: listData.length),
  ),
    );
  }
  var listData = <String>['文本及样式','按钮','图片及ICON','单选开关和复选框','输入框即表单','进度指示器'];
  var iconsData = <Icon>[ new Icon(Icons.text_fields),new Icon(Icons.bubble_chart),new Icon(Icons.image),new Icon(Icons.radio_button_checked),new Icon(Icons.text_fields),new Icon(Icons.text_format)];
  
  Widget buidData(BuildContext context,String titile ,Icon iconName,int index){
    return new ListTile(
      leading: iconName,
      title: Text(titile,
      style: TextStyle(
        fontSize: 14
      ),),
      trailing: new Icon(Icons.keyboard_arrow_right),
      onTap: (){
        if(index == 0){
          Navigator.push(context, MaterialPageRoute(builder: (context){
            return TextDemo();
          }));
        }else if(index == 1){
          Navigator.push(context, MaterialPageRoute(builder: (context){
return ButtonDemo();
          }));
        }else if(index == 2){
          Navigator.push(context, MaterialPageRoute(builder: (context){
return ImageDemo();
          }));
        }else if(index == 3){
          Navigator.push(context, MaterialPageRoute(builder: (context){
return SwitchAndCheckDemo();
          }));
        }else if(index == 4){
          Navigator.push(context, MaterialPageRoute(builder: (context){
return TextFieldDemo();
          }));
        }else if(index == 5){
          Navigator.push(context, MaterialPageRoute(builder: (context){
return ProgressDemo();
          }));
        }
      },

    );
  }

}